package top.infopub.mgr.common.intercepter;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import top.infopub.mgr.util.LogUtil;


/**
 * 用户后台访问记录拦截器
 * @author Awoke
 * @version 2018年10月15日
 * @see VisitLogIntercepter
 * @since
 */
public class VisitLogIntercepter implements HandlerInterceptor {

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
                                Object arg2, Exception arg3)
        throws Exception {}

    @Override
    public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2,
                           ModelAndView arg3)
        throws Exception {}

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse arg1, Object arg2)
        throws Exception {
        // 记录访问日志
        LogUtil.visitLog(request);
        return true;
    }

}
